var  _sj_browser = {
            versions: function () {
                var u = navigator.userAgent, app = navigator.appVersion;
                return {
                    trident: u.indexOf('Trident') > -1, 
                    presto: u.indexOf('Presto') > -1, 
                    webKit: u.indexOf('AppleWebKit') > -1, 
                    gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, 
                    //mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/), 
					mobile: !!u.match(/AppleWebKit.*Mobile.*/), 
                    ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), 
                    android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, 
                    iPhone: u.indexOf('iPhone') > -1 || u.indexOf('iphone') > -1, 
                    iPad: u.indexOf('iPad') > -1 || u.indexOf('ipad') > -1,  
                    webApp: u.indexOf('Safari') == -1 
                };
            } (),
            language: (navigator.browserLanguage || navigator.language).toLowerCase(),
			isBrowserMobile:function(){
			  return ( this.versions.mobile == true || this.versions.android == true || this.versions.iPhone == true || this.versions.iPad == true);
			},

			isWeixin:function(){
	                   var ua = navigator.userAgent.toLowerCase();
	                   if(ua.match(/MicroMessenger/i)=="micromessenger") {return true;} else {return false;}
            }
			
};


var cookieUtil = {
	set:function(key,val,time,domain){
		var date=new Date(); 
		var expiresDays=time; 
		date.setTime(date.getTime()+expiresDays*24*3600*1000); 
		var _cookiestr = key + "=" + val +";expires="+date.toGMTString();
		if(domain){_cookiestr+=";path=/;domain="+domain;}
		document.cookie= _cookiestr
		
	},
	get:function(key){ 
		 
		var getCookie = document.cookie.replace(/[ ]/g,"");  
		var arrCookie = getCookie.split(";")  
		var tips; 
		for(var i=0;i<arrCookie.length;i++){   
			var arr=arrCookie[i].split("=");   
			if(key==arr[0]){  
				tips=arr[1];   
				break;   
			} 
		}
		return tips;
	}
}

function getWeixinCodeImgSrc(){
  var _src = "http://www.yingteng.cc/images/weixinexam66.jpg";
  var _g = "";//分组
  var _s = "";//来源
  var _f = location.href;
  var _t = document.title;
  return _src;

}

function sjb(t,ev){
 alertBox_(t,ev);
}


var isIe_=(document.all)?true:false;
function setSelectState_(state){
	var objl=document.getElementsByTagName('select');
	for(var i=0;i<objl.length;i++){objl[i].style.visibility=state;}
}

function mousePosition_(ev){
if(ev.pageX || ev.pageY){return {x:ev.pageX, y:ev.pageY,e:ev};}
var x = y = 0;
    var doc = document.documentElement;
    var body = document.body;
    if (!ev) ev = window.event;
    if (window.pageYoffset) {
        x = window.pageXOffset;
        y = window.pageYOffset;
    } else {
        x = (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
        y = (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
    }
    x += ev.clientX;
    y += ev.clientY;
    return { "x": x, "y": y ,"e":ev};
}

function showMessageBox_(wTitle,content,pos,wWidth){
closeWindow_();
var bWidth=parseInt(document.documentElement.scrollWidth);
var bHeight=parseInt(document.documentElement.scrollHeight);
if(isIe_){
setSelectState_('hidden');}
var back=document.createElement("div");
back.id="back";
var styleStr="top:0px;left:0px;position:absolute;background:#666;width:"+bWidth+"px;height:"+bHeight+"px;";
styleStr+=(isIe_)?"filter:alpha(opacity=0);":"opacity:0;";
back.style.cssText=styleStr;
document.body.appendChild(back);
showBackground_(back,50);
var mesW=document.createElement("div");
mesW.id="mesWindow";
mesW.className="mesWindow";
mesW.innerHTML="<div class='mesWindowTop'><table width='100%' height='100%'><tr><td>"+wTitle+"</td><td align='right' style='width:50px;'><div onclick='closeWindow_();' style='cursor:pointer'>关闭</div></td></tr></table></div><div class='mesWindowContent' id='mesWindowContent'>"+content+"</div>";

var sTop = document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
var cTop = document.documentElement && document.documentElement.clientHeight?document.documentElement.clientHeight : document.body.clientHeight;
var cLeft = document.documentElement && document.documentElement.clientWidth?document.documentElement.clientWidth : document.body.clientWidth;
//if(cTop>700) cTop = 700;
	
var v_top =(cTop - 400)/2 +sTop;  
styleStr="top:"+(v_top)+"px;left:"+((cLeft-400)/2)+"px;position:absolute;width:509px; z-index:9999;background: #fff;border: 4px solid #D6E3E6;padding: 10px;";
mesW.style.cssText=styleStr;
document.body.appendChild(mesW);
}

function showBackground_(obj,endInt){
/*
if(isIe_ && obj.filters){
obj.filters.alpha.opacity+=5;
if(obj.filters.alpha.opacity<endInt){setTimeout(function(){showBackground_(obj,endInt)},5);}
}else{
var al=parseFloat(obj.style.opacity);al+=0.05;
obj.style.opacity=al;
if(al<(endInt/100))
{setTimeout(function(){showBackground_(obj,endInt)},5);}
}*/
}


function closeWindow_(){
if(document.getElementById('back')!=null){document.getElementById('back').parentNode.removeChild(document.getElementById('back'));}
if(document.getElementById('mesWindow')!=null){document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));}
if(isIe_){setSelectState_('');}
}

function alertBox_(t,ev){
/*
if(_sj_browser.isBrowserMobile()){
   if(location.href.indexOf("jsj")==-1){
	 location.href="http://vip.niukewang.com/shouji/";
	 return;
   }
}
*/

var objPos = mousePosition_(ev);
/*
var imgsrc = "http://www.niukewang.com/images/niukeweixin.gif";
var testurl = "http://vip.niukewang.com/shouji/";
if(location.href.indexOf("jsj")>0){
    imgsrc = "http://www.niukewang.com/images/weixin.jpg";
	testurl = "http://vip.niukewang.com/shouji/";
}
*/
var imgsrc = getWeixinCodeImgSrc();
imgsrc="http://www.niukewang.com/images/niukeapp.png"
messContent="<table border=0 width='100%' cellspacing='1' cellpadding='1' bgcolor='#c6cfd6'><tr><td bgcolor='#FFFFFF'><div class=\"smsbg1\"><div class=\"smssmg1\" style='font-size:13px;padding:0px;text-align:center'><img id='sjbrwm' src='"+imgsrc+"' height='150'><br><div style='text-align:center;'> </div> <div></div><div style=\"padding:0px;width:100%;cursor:pointer;position:relative;bottom:0px\"> <div style=\"width:50%;float:left;\" onclick=\"sjbcode(1)\"><img src=\"http://www.niukewang.com/images/androidlog.png\" style=\"vertical-align:middle;\"  width=\"32\">安卓版</div> <div style=\"\" onclick=\"sjbcode(2)\"><img src=\"http://www.niukewang.com/images/applelog.png\" style=\"vertical-align:middle;\" width=\"32\">苹果版</div></div></div></div></td><td bgcolor='#ffffff'><div class='mesText' style='padding:20px 0 0px 0;text-align:center;line-height:32px;'><h2 style=\"font-size:15px\"><!--<img src='http://www.niukewang.com/images/sidebar_wx.png' width='38' align='absmiddle'>-->手机版免费下载使用方法</h2> <p>  使用手机扫一扫左边二维码 即可免费试用。   <span id='waitstat'></span></p> <div id='sendstat'></div> <div style='text-align:center;padding:6px;font-size:14px'> <a href='http://wpa.qq.com/msgrd?v=3&uin=509228187&site=qq&menu=yes' target='_blank'>【不会用？点击联系客服教您使用】</a></div></div></td></table>";
showMessageBox_('手机版免费下载使用方法',messContent,objPos,350);
}

function sjbcode(i){
  if(i==1){
   document.getElementById("sjbrwm").src="http://www.niukewang.com/images/niukeapp.png";
  }
  else if(i==2){
     document.getElementById("sjbrwm").src="http://www.niukewang.com/images/niukeweixin.gif";
  }
}